package com.wanjia.bpsapi.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wanjia.bpsapi.mapper.WjStoreProductMapper;
import com.wanjia.bpsapi.pojo.dto.VegePrice;
import com.wanjia.bpsapi.pojo.entity.WjStoreProduct;
import com.wanjia.bpsapi.service.IWjStoreProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 商品表 服务实现类
 * </p>
 *
 * @author wyn
 * @since 2023-02-13
 */
@Service
public class WjStoreProductServiceImpl extends ServiceImpl<WjStoreProductMapper, WjStoreProduct> implements IWjStoreProductService {


    @Autowired
    WjStoreProductMapper wjStoreProductMapper;

    @Override
    public List<VegePrice> getPrice(String storeName, Long clientId) {
        List<VegePrice> priceList = wjStoreProductMapper.getPrice(storeName,clientId);
        return priceList;
    }

    @Override
    public int addProduct(WjStoreProduct wjStoreProduct) {
        /*Integer id = wjStoreProduct.getId();
        WjStoreProduct data = wjStoreProductMapper.selectById(id);
        if (data !=null){
            wjStoreProductMapper.deleteById(data.getId());
        }*/
        //wjStoreProductMapper.delete(new QueryWrapper<>());
        int i = wjStoreProductMapper.insert(wjStoreProduct);
        return i;
    }

    @Override
    public List<VegePrice> getOtherPrice(Long vegeId, Long clientId) {
        return wjStoreProductMapper.getOtherPrice(vegeId, clientId);
    }


}
